<?php

class ModAdmin
{
	private function auth()
	{
		if( !sessionLayer::isGamemasterAccount() )
		{
			viewLayer::render( NULL, "You are not authorized to view this section." );
			return false;
		}
		
		return true;
	}
	
	public function index()
	{
		if( $this->auth() )
		{
			viewLayer::$var->adminDashboard = nl2br(htmlspecialchars( configLayer::get('admin_dashboard') ));
			viewLayer::render( 'admin' );
		}
	}
	
	public function config()
	{
		if( $this->auth() )
		{
			if( $_POST['smtp_mail'] )
			{
				foreach( $_POST as $ConfigKey => $ConfigValue )
				{
					configLayer::set( $ConfigKey, $ConfigValue );
				}
			
				viewLayer::render( NULL, "Config updated successfully." );
			}
			
			viewLayer::$var->config = configLayer::getAll();
			viewLayer::render( 'admin_config' );
		}
	}
	
	public function players()
	{
		if( $this->auth() )
		{
			viewLayer::$var->pList = new OTS_Players_List;
			viewLayer::$var->rAccess = configLayer::get('hs_gm_access');
			viewLayer::render( 'admin_players' );
		}
	}
}
?>